package utils

import "log"

func Try(fun func(), handler func(interface{})) {
	defer func() {
		if err := recover(); err != nil {
			handler(err)
		}
	}()
	fun()
}

func SafeGoFunc(fun func()) {
	go func() {
		Try(fun, func(e interface{}) {
			log.Printf("SafeGoFunc error! err:%v\n", e)
		})
	}()
}
